package network_programming.np1_socket_and_serversocket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 负责关闭服务器程序
 * */
public class EchoServerAdminClient {
    public static void main(String[] args) {
        try (Socket socket = new Socket("localhost", 9100)) {
            OutputStream socketOS = socket.getOutputStream();
            socketOS.write("shutdown\r\n".getBytes());
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String msg = null;
            while ((msg = br.readLine()) != null)
                System.out.println(msg);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
